package com.slicktechnologies.client.views.settings.user;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;

import java.util.Vector;

import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.*;
import com.simplesoftwares.client.library.appstructure.search.*;
import com.simplesoftwares.client.library.appstructure.formtablescreen.*;
import com.slicktechnologies.shared.*;
import com.slicktechnologies.shared.common.*;
import com.slicktechnologies.shared.common.businessprocesslayer.*;
import com.slicktechnologies.shared.common.businessunitlayer.*;
import com.slicktechnologies.shared.common.helperlayer.*;
import com.slicktechnologies.shared.common.personlayer.*;
import com.slicktechnologies.shared.common.productlayer.*;

import java.util.Vector;

import javax.jws.soap.SOAPBinding.Use;

import com.simplesoftwares.client.library.appstructure.search.*;
import com.simplesoftwares.rebind.annatonations.EntityNameAnnotation;
import com.google.gwt.core.shared.GWT;
import com.simplesoftwares.client.library.appstructure.SearchPopUpScreen;
import com.simplesoftwares.client.library.appstructure.SuperTable;
import com.slicktechnologies.client.utility.GeneratedVariableRefrence;
import com.simplesoftwares.client.library.appskeleton.AppMemory;
import com.slicktechnologies.shared.common.paymentlayer.*;
import com.google.gwt.event.dom.client.*;
/**
 *  FormTableScreen presenter template
 */
public class UserPresenter extends FormTableScreenPresenter<User>  {

	//Token to set the concrete form
	UserForm form;
	
	public UserPresenter (FormTableScreen<User> view,
			User model) {
		super(view, model);
		form=(UserForm) view;
		form.getSupertable().connectToLocal();
		form.retriveTable(getUserQuery());
		form.setPresenter(this);
	}

	/**
	 * Method template to set the processBar events
	 */
	@Override
	public void reactToProcessBarEvents(ClickEvent e) 
   {
		InlineLabel label=(InlineLabel) e.getSource();
		String text=label.getText().trim();
		
		if(text.equals(""))
  reactTo();

		
	}
	
	

	@Override
	public void reactOnPrint() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void reactOnEmail() {
		// TODO Auto-generated method stub
		
	}

	/**
	 * Method template to set new model
	 */
	@Override
	protected void makeNewModel() {
		
		model=new User();
	}
	
	/*
	 * Method template to set Myquerry object
	 */
	public MyQuerry getUserQuery()
	{
		MyQuerry quer=new MyQuerry(new Vector<Filter>(), new User());
		return quer;
	}
	
	public void setModel(User entity)
	{
		model=entity;
	}
	
	public static void initalize()
	{
			 UserPresenterTable gentableScreen=GWT.create( UserPresenterTable.class);
			
			UserForm  form=new  UserForm(gentableScreen,FormTableScreen.UPPER_MODE,true);
			gentableScreen.setView(form);
			gentableScreen.applySelectionModle();
			
			   UserPresenterTable gentableSearch=GWT.create( UserPresenterTable.class);
			   TextColumn<User>salesPerson=(TextColumn<User>) gentableSearch.getTable().getColumn(0);
			   gentableSearch.getTable().setColumnWidth(salesPerson,60,Unit.PX);
				
			    // UserPresenterSearch.staticSuperTable=gentableSearch;
			     //  UserPresenterSearch searchpopup=GWT.create( UserPresenterSearch.class);
			       //    form.setSearchpopupscreen(searchpopup);
			
			 UserPresenter  presenter=new  UserPresenter  (form,new User());
			AppMemory.getAppMemory().stickPnel(form);
			
			
		 
	}
	
	
		@EntityNameAnnotation(EntityName = "com.slicktechnologies.shared.common.helperlayer.User")
		 public static class  UserPresenterTable extends SuperTable<User> implements GeneratedVariableRefrence{

			@Override
			public Object getVarRef(String varName) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void createTable() {
				// TODO Auto-generated method stub
				
			}

			@Override
			protected void initializekeyprovider() {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void addFieldUpdater() {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void setEnable(boolean state) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void applyStyle() {
				// TODO Auto-generated method stub
				
			}} ;
			
			@EntityNameAnnotation(EntityName = "com.slicktechnologies.shared.common.helperlayer.User")
			 public static class  UserPresenterSearch extends SearchPopUpScreen<  User>{

				@Override
				public MyQuerry getQuerry() {
					// TODO Auto-generated method stub
					return null;
				}};
				
	  private void reactTo()
  {
}
	

}
